﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project_Udrinkwater
{
    public partial class ShowDataEmp : System.Web.UI.Page
    {
        string Connection = ConfigurationManager.ConnectionStrings["DB_Udrink"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
                DataTable TB_Emp = new DataTable();
                string sqltext = @"SELECT TB_Employee.Employee_ID, TB_Employee.Prefix, TB_Employee.FirstName, 
                                   TB_Employee.LastName, TB_Employee.Address, TB_Employee.Tel, TB_Employee.Salary, 
                                   TB_Department.Department_Name, TB_Employee.StartJob, TB_Province.PROVINCE_NAME, 
                                   TB_District.DISTRICT_NAME, TB_Amphur.AMPHUR_NAME FROM TB_Employee 
                                   INNER JOIN TB_Department ON TB_Employee.Departmernt_ID = TB_Department.Department_ID 
                                   INNER JOIN TB_Amphur ON TB_Employee.AMPHUR_ID = TB_Amphur.AMPHUR_ID 
                                   INNER JOIN TB_District ON TB_Employee.DISTRICT_ID = TB_District.DISTRICT_ID 
                                   AND TB_Amphur.AMPHUR_ID = TB_District.AMPHUR_ID INNER JOIN TB_Province 
                                   ON TB_Employee.PROVINCE_ID = TB_Province.PROVINCE_ID AND 
                                   TB_Amphur.PROVINCE_ID = TB_Province.PROVINCE_ID AND TB_District.PROVINCE_ID = TB_Province.PROVINCE_ID
                                   WHERE TB_Employee.Employee_ID = '" + Session["User"].ToString() + "'";
            SqlConnection sqlconn = new SqlConnection(Connection);
            SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
            DataSet ds = new DataSet();
            da.Fill(ds);

            TB_Emp = ds.Tables[0];

            lb_Prefix.Text = TB_Emp.Rows[0]["Prefix"].ToString();
            lb_showname.Text = TB_Emp.Rows[0]["FirstName"].ToString();
            lb_showlname.Text = TB_Emp.Rows[0]["LastName"].ToString();
            lb_showposition.Text = TB_Emp.Rows[0]["Department_Name"].ToString();
            lb_showaddress.Text = TB_Emp.Rows[0]["Address"].ToString();
            lb_showsalary.Text = TB_Emp.Rows[0]["Salary"].ToString();
            lb_District.Text = TB_Emp.Rows[0]["DISTRICT_NAME"].ToString();
            lb_Aumphure.Text = TB_Emp.Rows[0]["AMPHUR_NAME"].ToString();
            lb_Province.Text = TB_Emp.Rows[0]["PROVINCE_NAME"].ToString();
            lb_showstartjob.Text = Convert.ToDateTime(TB_Emp.Rows[0]["StartJob"]).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("th-TH"));
            
            
        }

        protected void bt_OK_Click(object sender, EventArgs e)
        {
        }

        //    else
        //    {
        //        Response.Write(@"<script language='javascript'>alert('รหัสผ่านไม่ถูกต้อง')</script>");
        //    }
        //}

        protected void bt_selectEmp0_Click(object sender, EventArgs e)
        {
            //string[] Employee = (cb_ShowcodeEmp.SelectedItem.Text).Split(' ');
            //string Emp_ID = Employee[0];
            //Session["Emp_ID"] = Emp_ID;
            //Response.Redirect("Salary_Emp.aspx");

        }

       
    }
}